/*
 * @Author: 郝奔 1425466221@qq.com
 * @Date: 2024-12-02 16:31:43
 * @LastEditors: gaoyu gy15354315043@163.com
 * @LastEditTime: 2025-01-13 13:46:44
 * @FilePath: /HG-dqbasic_open_platform/src/framework/router/index.ts
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */

/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import { usePermissionStoreHook } from '@/framework/store/modules/permission';
export const PLATFORM_MESSAGE = '/messageCenter/platformMessage'
export const NOTICE_LIST = '/messageCenter/noticeList'
export const noticePaths = [PLATFORM_MESSAGE, NOTICE_LIST, '/message-detail']
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const Layout = () => import('@/framework/layout/index.vue');
export const navigationTop = () => import('@/framework/layout/navigationTop.vue');
export const navigationPage = () => import('@/framework/layout/navigationPage.vue');


// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    component: navigationPage,
    path: '/selfLayout401',
    redirect: '/401',
    children: [
      {
        path: '/401',
        component: () => import('@/framework/views/error-page/401.vue'),
        meta: { hidden: true }
      },
      {
        path: '/auth',
        component: () => import('@/framework/views/error-page/auth.vue'),
        meta: { hidden: true }
      },
    ]
  },

];

// 创建路由
const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 })
});

// 重置路由
export function resetRouter(): void {
  const permissionStore = usePermissionStoreHook();
  permissionStore.routes.forEach(route => {
    const name = route.name;
    if (name && router.hasRoute(name)) {
      router.removeRoute(name);
    }
  });
}

export default router;
